<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />    
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script></head>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
</head>
<body>
    <header class="header header-f" style="padding-top:2rem; height:4rem;">
        <div class="header-l aui-pull-left" onclick="closeWin()">
            <i class="fa fa-angle-left"></i>
        </div>
        <div class="header-title">
            消费排行
        </div>
        <div class="header-r aui-pull-right">
        </div>
    </header>
    <div style="height:4rem;"></div>

    <div class="my-task-volcano-d-t">
        <div>名次</div>
        <div>用户名</div>
        <div>消费金额(元)</div>
    </div>
    <div class="my-task-volcano-list" id="list">
<!--         <div class="my-task-volcano-d">
            <div class="my-task-volcano-d-s">
                <image mode="widthFix" src="images/my-task-volcano-1.png"></image>
                Anny_静静
                <div>￥10688.00</div>
            </div>
        </div>
        <div class="my-task-volcano-d">
            <div class="my-task-volcano-d-s">
                <image mode="widthFix" src="images/my-task-volcano-2.png"></image>
                Anny_静静
                <div>￥10688.00</div>
            </div>
        </div>
        <div class="my-task-volcano-d active">
            <div class="my-task-volcano-d-s">
                <image mode="widthFix" src="images/my-task-volcano-3.png"></image>
                Anny_静静
                <div>￥10688.00</div>
            </div>
        </div>
        <div class="my-task-volcano-d">
            <div class="my-task-volcano-d-s">
                <span>4</span>
                Anny_静静
                <div>￥10688.00</div>
            </div>
        </div>
        <div class="my-task-volcano-d">
            <div class="my-task-volcano-d-s">
                <span>5</span>
                Anny_静静
                <div>￥106808.00</div>
            </div>
        </div> -->
    </div>

</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/template" id="template">
    {{~it:value:index}}
    <div class="my-task-volcano-d">
        <div class="my-task-volcano-d-s">
            {{? index == 0}}
            <image mode="widthFix" src="images/my-task-volcano-1.png"></image>
            {{?? index == 1}}
            <image mode="widthFix" src="images/my-task-volcano-2.png"></image>
            {{?? index == 2}}
            <image mode="widthFix" src="images/my-task-volcano-3.png"></image>
            {{??}}
            <span>{{=index+1}}</span>
            {{?}}
            {{=value.nickname}}
            <div>{{=value.price}}</div>
        </div>
    </div>
    {{~}}
</script>
<script type="text/javascript">
    apiready = function(){
        loadData();
    }
    
    function loadData(){
        var userid = $api.getStorage('userid');
        var authtoken = $api.getStorage('authtoken');
        api.ajax({
            url: webAddress + '/a/order/order/ranking',
            method: 'post',
            data: {
                values: {
                },
            },
            headers: {
                TOKEN: token,
                authuid: userid,
                authtoken: authtoken,
                'Content-Type': 'application/x-www-form-urlencoded',
            },
        },function(ret, err){
            if (ret) {
                // alert( JSON.stringify( ret ) );

                templateFun(ret.result.data.pageList);
            } else {

                // alert( JSON.stringify( err ) );
                var data = new Array();
                templateFun(data);
                return false;
            }
        });
    }

    // 模板赋值函数
    function templateFun(data){
        if (data.length) {
            var template = $api.byId('template');
            var dotFn = doT.template(template.innerHTML);
            var html = dotFn(data);
            var list = $api.byId('list');
            $api.html(list, html);
        }else{

          var list = $api.byId('list');
          var html = '<h2 style="padding:1rem; text-align:center; color:#999; font-size:1rem;">暂无优惠券</h2>';
          list.innerHTML = html;
      }
  }
  
  function closeWin(){
    api.closeWin({
    });
}
</script>
</html>